Skip to content

[mlir][IntRange] Poison support in int-range analysis #152932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Hardcode84
Copy link
Contributor

No description provided.

@Hardcode84 Hardcode84 force-pushed the int-range-poison branch 2 times, most recently from bc195a7 to acd1e54 Compare August 10, 2025 19:29
Copy link
Contributor

@krzysz00 krzysz00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of anything obviously wrong here, I'm just uneasy.

And am curious about how ValueTracking.cpp or KnownBits down in LLVM handle this sort of thing.

@@ -96,6 +103,14 @@ class ConstantIntRanges {
/// value.
std::optional<APInt> getConstantValue() const;

/// Returns true if signed range is poisoned, i.e. no valid signed value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I agree with "no valid value" as the semantics here. We need to be much clearer that a poisoned range is one that's the result of undefined behavior, and this is assumed to be impossible.

@@ -306,7 +329,8 @@ static ConstantIntRanges inferDivURange(const ConstantIntRanges &lhs,

// X u/ Y u<= X.
APInt umax = lhsMax;
return ConstantIntRanges::fromUnsigned(umin, umax);
return propagatePoison(ConstantIntRanges::fromUnsigned(umin, umax),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something feels off about the fact that you have to stick these calls everywhere, but maybe that's just how it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants